package com.tepth.vehiclemaintenance.mvp.main;

import com.tepth.vehiclemaintenance.bean.VehicleMaintain;
import com.tepth.vehiclemaintenance.net.ApiModel;
import com.tepth.vehiclemaintenance.net.Network;

import java.util.ArrayList;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by TMVPHelper on 2017/05/08
 */
public class MainModel implements MainContract.Model {

    @Override
    public Observable<ApiModel<ArrayList<VehicleMaintain>>> getMainList(String authKey, String startTime, String endTime) {
        return Network.getApiService().getMainList(authKey, startTime, endTime)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<ApiModel<ArrayList<String>>> getNotFinishList(String authKey, String startDate, String endDate) {
        return Network.getApiService().getNotFinishWorkDate(authKey, startDate, endDate)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<ApiModel<String>> startWork(String authKey, int maintenanceId) {
        return Network.getApiService().startWork(authKey, maintenanceId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
}